#!/bin/bash

if [ !  -d certs ];then
mkdir certs

# rm certs/*
echo "make server cert"
openssl req -new -nodes -x509 -out certs/server.pem -keyout certs/server.key -days 3650 -subj "/C=DE/ST=NRW/L=Earth/O=Random Company/OU=IT/CN=www.random.com/emailAddress=$1"
echo "make client cert"
openssl req -new -nodes -x509 -out certs/client.pem -keyout certs/client.key -days 3650 -subj "/C=DE/ST=NRW/L=Earth/O=Random Company/OU=IT/CN=www.random.com/emailAddress=$1"
openssl req -new -key server.key -x509 -days 3650 -out server.crt -subj "/C=DE/ST=NRW/L=Earth/O=Random Company/OU=IT/CN=www.random.com/emailAddress=$1"
openssl req -new -key client.key -x509 -days 3650 -out client.crt -subj "/C=DE/ST=NRW/L=Earth/O=Random Company/OU=IT/CN=www.random.com/emailAddress=$1"

fi

if [ ! -d certs2 ];then
mkdir certs2

echo "make server cert"
openssl req -new -nodes -x509 -out certs2/server.pem -keyout certs2/server.key -days 3650 -subj "/C=JP/ST=NRW/L=Earth/O=Random Company/OU=IT/CN=www.random.com/emailAddress=$1"
echo "make client cert"
openssl req -new -nodes -x509 -out certs2/client.pem -keyout certs2/client.key -days 3650 -subj "/C=JP/ST=NRW/L=Earth/O=Random Company/OU=IT/CN=www.random.com/emailAddress=$1"

openssl req -new -key server.key -x509 -days 3650 -out server.crt -subj "/C=JP/ST=NRW/L=Earth/O=Random Company/OU=IT/CN=www.random.com/emailAddress=$1"
openssl req -new -key client.key -x509 -days 3650 -out client.crt -subj "/C=JP/ST=NRW/L=Earth/O=Random Company/OU=IT/CN=www.random.com/emailAddress=$1"


fi
